<%@ tag language="java" pageEncoding="UTF-8" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<%@ attribute name="moduleCode" required="true" rtexprvalue="true"%>

<div id="userFavouritePanel"  ng-controller="UserFavouriteCtrl" class="ng-cloak">   
  <div class="media" style="border-bottom: 1px dashed #EAEAEA;" ng-repeat="row in userFavourites" id="favouriteRow{{$index}}">
    <div class="media-body" ng-mouseover="showflag=1" ng-mouseleave="showflag=0" ng-init="showflag=0">
      <p class="media-heading " ><a href="${contextPath}{{row.recordUrl}}?id={{row.recordId}}">{{row.recordName}} </a>
      <span class="tools pull-right"  ng-show="showflag" >
        <a href="${contextPath }/oa/shareFile/open.do?id={{row.recordId }}" target="_blank" title="直接打开"><i class="icon-eye-open"></i></a>&nbsp;
        <a href="${contextPath }/oa/shareFile/download.do?id={{row.recordId }}" target="_blank" title="直接下载"><i class="icon-cloud-download"></i></a>&nbsp;
        <a title="<s:message code='userFavourite.func.remove'/>" ng-click="remove($index)"><i class="icon-remove"></i></a>                                                                             
      </span>      
      </p>
    </div>
  </div>  
</div>

<script type="text/javascript">
function UserFavouriteCtrl($scope, $http) {
  $scope.userFavourites = [];
  //init
  $http.get('${contextPath}/oa/shareFile/getUserFavourites.json?moduleCode=${moduleCode}', {
  }).success(function(data) {
      $scope.userFavourites = data.userFavourites; 
  }); 

  $scope.remove=function(index){
	  var userFavourite=$scope.userFavourites[index];
	  $http.get('${contextPath}/assistant/userFavourite/delete.json?id='+userFavourite.id, {
	  }).success(function(data){
		  $scope.userFavourites.splice(index,1);
	  } );
  }
}
</script> 